//
//  HJRepairSettlementHeaderView.m
//  GAMCAfterSales
//
//  Created by 贺佳 on 2018/5/16.
//  Copyright © 2018年 glendale. All rights reserved.
//

#import "HJRepairSettlementHeaderView.h"

@interface HJRepairSettlementHeaderView()
/**
 标题数组
 */
@property(nonatomic,strong)NSArray*titleAry;
@end
@implementation HJRepairSettlementHeaderView
-(NSArray *)titleAry
{
    if (!_titleAry) {
        _titleAry=@[@"作业单号:",@"牌  照  号:",@"车  架  号:",@"车型名称:",@"接待日期:",@"预交车日:",@"送  修  人:",@"客户名称:"];
    }
    return _titleAry;
}
InitFrameM
-(void)setUI{
   
    for (int i=0; i<self.titleAry.count; i++) {
        UIView*subView=[[UIView alloc]init];
        [self addSubview:subView];
        
        UILabel*leftLabel=[[UILabel alloc]init];
        leftLabel.text=self.titleAry[i];
        leftLabel.font=[UIFont systemFontOfSize:15];
        [subView addSubview:leftLabel];
        [leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.bottom.mas_equalTo(subView);
            make.width.mas_equalTo(70);
        }];
        
        UIView*bgView=[UIView new];
        [subView addSubview:bgView];
        bgView.backgroundColor=[UIColor grayColor];
        [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.right.bottom.mas_equalTo(subView);
            make.left.mas_equalTo(leftLabel.mas_right).offset(5);
        }];
        
        UITextField*textField=[[UITextField alloc]init];
        [subView addSubview:textField];
        textField.backgroundColor=[UIColor whiteColor];
        textField.tag=i;
        textField.textAlignment=NSTextAlignmentCenter;
        [textField addTarget:self action:@selector(textFieldChange:) forControlEvents:UIControlEventEditingChanged];
        [textField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.right.bottom.left.mas_equalTo(bgView).inset(1);
        }];
    }
}
-(void)setRepairSettlementModel:(HJRepairSettlementModel *)repairSettlementModel
{
    _repairSettlementModel=repairSettlementModel;
    
    // _titleAry=@[@"作业单号:",@"牌  照  号:",@"车  架  号:",@"车型名称:",@"接待日期:",@"预交车日:",@"送  修  人:",@"客户名称:"];
    int i =0;
    HJRepairSettlementTT_RepairOrderItemModel*repairSettlementTT_RepairOrderItemModel=repairSettlementModel.TT_REPAIR_ORDER_ITEM[0];
    for (UIView*subView in self.subviews) {
        UITextField*textField=[subView.subviews lastObject];
        switch (i) {
            case 0:
                textField.text=repairSettlementTT_RepairOrderItemModel.RO_NO;
                break;
            case 1:
                textField.text=repairSettlementTT_RepairOrderItemModel.PLATE_NUMBER;
                break;
            case 2:
                textField.text=repairSettlementTT_RepairOrderItemModel.VIN;
                break;
            case 3:
                textField.text=repairSettlementTT_RepairOrderItemModel.MODEL;
                break;
            case 4:
                textField.text=repairSettlementTT_RepairOrderItemModel.IN_TIME;
                break;
            case 5:
                textField.text=repairSettlementTT_RepairOrderItemModel.END_TIME_SUPPOSED;
                break;
            case 6:
                textField.text=repairSettlementTT_RepairOrderItemModel.DELIVERER;
                break;
            case 7:
                textField.text=repairSettlementTT_RepairOrderItemModel.OWNER_NAME;
                break;
                
            default:
                break;
        }
        i++;
    }
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat margin=20;
    int row=3;
    CGFloat h=35;
    CGFloat w=(self.mj_w-(row-1)*margin)/row;
    int i=0;
    for (UIView*subView in self.subviews) {
        subView.frame=CGRectMake(i/row*(margin+w), i%row*(margin+h), w, h);
        i++;
    }
}
@end
